<?php
include("../dbConn.php");
class validate{
    public $status = "";
    public $username="";
}
if($_SERVER['REQUEST_METHOD']=="POST"){
    $usernameBase = $_POST['username'];
    $passwdBase = $_POST['passwd'];
    $username = base64_decode($usernameBase);
    $passwd = base64_decode($passwdBase);
    $sql = sprintf("select count(*) from users where username='%s' and password='%s'",$username,$passwd);
    $rawResult = mysql_query($sql,dbConn());
    $num = mysql_fetch_array($rawResult);
    $res = new validate();
    if($num[0]>=1){
        $sql = sprintf("select * from users where username='%s' and password='%s'",$username,$passwd);
        $rawResult = mysql_query($sql,dbConn());
        $result = mysql_fetch_array($rawResult);
        //var_dump($result);
       if($result['ban']==0){
           $res->status ="0";
           $res->username = $result['username'];
           $returnJson = json_encode($res);
           $return = base64_encode($returnJson);
           echo $return;
       }else{
           $res->status ="2";
           //$res->username = $result['username'];
           $returnJson = json_encode($res);
           $return = base64_encode($returnJson);
           echo $return;
       }


    }else{
        $res->status ="1";
        //$res->username = $result['username'];
        $returnJson = json_encode($res);
        $return = base64_encode($returnJson);
        echo $return;
    }

}
?>